<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/reset.css">
    <style>
        .content{
            width: 400px;
            height: 200px;
            display: block;
            margin: 50px auto;
        }
    </style>
</head>
<body>
    <textarea class="content" autofocus cols="30" rows="10"></textarea>
</body>
<script>
    var content = document.getElementsByClassName("content")[0];

    //键盘事件的事件对象

    content.addEventListener("compositionstart",function(){
        console.log("中文开始输入");
    })
    content.addEventListener("compositionupdate",function(e){
        console.log("中文正在输入",e.data);
    })
    content.addEventListener("compositionend",function(){
        console.log("中文输入结束");
    })
    


</script>
</html>